
function query_Application(page) {
	sys_loading();
	var parm = $('#queryApplicationForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('application-query');
	sys_record_parm('application',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#applicationSesultList').html(result);
		}
	});
}


function aidExecuteApply_Application(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功!');
				query_Application();
			} else {
				sys_warning('操作失败', '操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}



function shield_Application(code, title) {
	$.Zebra_Dialog('确认要屏蔽标题为： ' + title + ' 的申请单信息吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
	           {caption:'屏蔽',callback:function() {
	        	   var url = create_url('application-shield');
	        	   aidExecuteApply_Application(code, url);
	    		}},
	           {caption:'取消',callback:function(){}
	    	}]
	});
}

function unshield_Application(code, title) {
	$.Zebra_Dialog('确认要解除标题为： ' + title + ' 申请单的屏蔽状态吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
	           {caption:'屏蔽',callback:function() {
	        	   var url = create_url('application-unshield');
	        	   aidExecuteApply_Application(code, url);
	    		}},
	           {caption:'取消',callback:function(){}
	    	}]
	});
}
/*************************************************edit*****************************/

function selectDetail_Application(btn) {
	var i = btn.attr('pib');
	var parm = {'index':i};
	
	var url = create_url('application-aidInit');
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'1200px', height:'700px', open:true, 
		onClosed:function(){
		}
	});
}

function deleteDetail_Application(btn) {
	btn.parents('.rep').remove();
}


function createTitle_Application() {
	var title = '';
	var temp = null;
	$('#applicationDetailListBody').find('.rep').each(function () {
		temp = $(this).find('select.vtn').find('option:selected').text();
		
		if ('' != temp) {
			title += temp;
			temp = $(this).find('.cou').val();
			if ('' != temp)
				title += '(' + temp  + ')';
			title += '    ';
		}
	});
	
	$('#title').val(title);
}

function addDetail_Application() {
	var tr = $('#tempApplicationDetailTable').find('tr').clone(true);
	var i = $('#index').val();
	tr.find('.ac').attr('id', 'ac_' + i).attr('name', 'detaisList[' + i + '].ac').end()
		.find('.btn-primary').attr('pib', i).end()
		.find('.un').attr('id', 'un_' + i).end()
		.find('.vtn').attr({"name":'detaisList[' + i + '].vt'}).end();
	
	$('#applicationDetailListBody').append(tr);
	$('#index').val(parseInt(i) + 1);
}

function save_Application() {
	alert(3333333333333333333);
	var parm = $('#editApplicationForm').serialize();
	var url = create_url('application-save');
	sys_submiting();
	alert(22222222222222222);
	$.ajax({type:'POST',url:url,data:parm,
		success: function(result) {
			alert(111111111111111111111111);
			alert(resilt);
			sys_submiting_close();
			if (result == 'success') {
				sys_load_handle('application');
			} else if(result == 'parameter_error'){
				sys_warning('您还有选项没有填写哦!不填写数量或商品是不会保存的！ 请检查  -_-');
			} else{
				sys_warning('操作失败!');
			}
		}
	});
}